import React, { PureComponent } from 'react';
import { connect } from 'dva';

import { Row, Col, Icon, Form, Button, Avatar, InputNumber, Popconfirm, Modal, AutoComplete, Input, Divider } from 'antd';

import styles from './styles.less';

const FormItem = Form.Item;

const ModelName = "box";
@connect(({ loading }) => ({
  loading: loading.models[ModelName],
}))
@Form.create()
class Comp extends PureComponent {

  constructor(props) {
    super(props);

    const { getInstance } = props;
    if (typeof getInstance === 'function') {
      getInstance(this);
    }
  }

  componentDidMount() {

  }

  render() {
    const { form: { getFieldDecorator }, } = this.props;
    const { current, mbl, visible, onOk, onCancel } = this.props;

    const getModalContent = () => {
      const formItemLayout = {
        labelCol: {
          lg: { span: 6 },
          xs: { span: 6 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 15 },
          sm: { span: 15 },
        },
        style: {
          marginBottom: '1.5em',
        }
      };


      return (
        <Form onSubmit={this.handleSubmit}>
          <FormItem label="货柜号" {...formItemLayout}>
            {getFieldDecorator('objectNumber', {
              rules: [{ required: true, message: '请输入货柜号' }],
              initialValue: current.objectNumber,
            })(
              <Input />
            )}
          </FormItem>
          <FormItem label="封条号" {...formItemLayout}>
            {getFieldDecorator('sealNumber', {
              rules: [{ required: true, message: '请输入封条号' }],
              initialValue: current.sealNumber,
            })(<Input />)}
          </FormItem>
          <FormItem label="件数" {...formItemLayout}>
            {getFieldDecorator('qty', {
              initialValue: current.qty,
            })(
              <Input addonAfter={mbl.qtyPOM} />
            )}
          </FormItem>
          <FormItem label="重量" {...formItemLayout}>
            {getFieldDecorator('weight', {
              initialValue: current.weight,
            })(
              <Input addonAfter={mbl.weightPOM} />
            )}
          </FormItem>
          <FormItem label="体积" {...formItemLayout}>
            {getFieldDecorator('measure', {
              initialValue: current.measure,
            })(
              <Input addonAfter={mbl.measurePOM} />
            )}
          </FormItem>
        </Form>
      );
    };

    return (
      <Modal
        title={'编辑'}
        bodyStyle={{ padding: '28px 0 0' }}
        destroyOnClose
        visible={visible}
        onOk={onOk}
        onCancel={onCancel}
      >{getModalContent()}
      </Modal>
    );
  }
}

export default Comp;

